#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
int a[N], b[N], c[N];
int as[N], cs[N];
int cnt[N], s[N];
int n;
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]++;
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		b[i]++;
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		c[i]++;
	}
	for (int i = 0; i < n; i++) {
		cnt[a[i]]++;
	}
	for (int i = 1; i < N; i++) {
		s[i] = s[i - 1] + cnt[i];
	}
	for (int i = 0; i < n; i++) {
		as[i] = s[b[i] - 1];	
	}
	memset(cnt, 0, sizeof(cnt));
	memset(s, 0, sizeof(s));
	for (int i = 0; i < n; i++) {
		cnt[c[i]]++;
	}
	for (int i = 1; i < N; i++) {
		s[i] = s[i - 1] + cnt[i];
	}
	for (int i = 0; i < n; i++) {
		as[i] = s[N] - s[b[i]];
	}
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		ans += (LL)as[i] * cs[i];	
	}
	cout << ans << endl;
	return 0;
}